<?php
class MailsController extends AppController
{
	var $name = 'Mails';
	var $uses = 'Mail';
	var $helpers = array('Html', 'Form', 'Javascript','Flash');
	var $components = array('Email', 'Session');
	
	function index(){	  	
		if(isset($this->data)) {
			$this->Mail->create($this->data);

			    
			    $this->data['Mail']['message'].= "\r\n".'---------------------------------------';
			    $this->data['Mail']['message'].= "\r\n".'Nombre: '.$this->data['Mail']['name'];
			    $this->data['Mail']['message'].= "\r\n".'Nombre Empresa: '.$this->data['Mail']['nombre_empresa'];
			    $this->data['Mail']['message'].= "\r\n".'Email: '.$this->data['Mail']['email'];
			    $this->data['Mail']['message'].= "\r\n".'Ciudad: '.$this->data['Mail']['city'];
			    $this->data['Mail']['message'].= "\r\n".'Direccion: '.$this->data['Mail']['direccion'];
			    $this->data['Mail']['message'].= "\r\n".'URL: '.$this->data['Mail']['url'];
			    $this->data['Mail']['message'].= "\r\n".'Movil: '.$this->data['Mail']['celular'];
							
				$this->Email->to = 'info@publicidadyclasificados.com';//mail aqui
				$this->Email->replyTo = $this->data['Mail']['email'];
				$this->Email->from = $this->data['Mail']['name'].' <'.$this->data['Mail']['email'].'>';
				$this->Email->subject = "Mensaje Asunto ". $this->data['Mail']['asunto'];
				//$this->Email->delivery = 'debug';
				if ($this->Email->send($this->data['Mail']['message'])) {
					
					$this->redirect(array('/'.$this->data['Mail']['from']));
				} else {
					$this->Session->setFlash('No se pudo mandar el mail');
				}
				$this->redirect(array('/'.$this->data['Mail']['from']));
	
		}
	}
	
}
?>
